package com.kitty.game.gm.handler;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.party.model.Party;
import com.kitty.game.party.service.PartyService;
import com.kitty.game.role.model.Role;
import com.kitty.mina.message.MessagePusher;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;



public class GmBangpai implements GMFather {

    @Override
    public boolean handle(Role gm, String content) {
        String[] names = content.split("##");
        Dao dao = SpringUtils.getBean(Dao.class);
        Party party = dao.fetch(Party.class, Cnd.where("partyName", "=", names[0]));
        if (party == null) {
            MessagePusher.pushMessage(gm, new RespNotifyMiscEx("帮派不存在"));
            return true;
        }
        PartyService partyService = SpringUtils.getPartyService();
        party = partyService.getParty(party.getId());
        party.setPartyName(names[1]);
        if (names.length == 3){
            party.setNotice(names[2]);
        }else {
            party.setNotice(names[1]);
        }
        party.save();
        MessagePusher.pushMessage(gm, new RespNotifyMiscEx("修改成功！！！"));
        return true;
    }
}
